home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / SetSpeakerPhone.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-05  |  4.1 KB  |  139 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    SetSpeakerPhone                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        SetSpeakerPhone.c                                                            */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1994-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1994-07-27    Gary Anwyl            Original version                                        */
  15. /*                                                                                                */
  16. /************************************************************************************************/
  17.  
  18. /****************************************** DESCRIPTION ******************************************
  19.  
  20.     This module display a dialog box in which the user can enable or
  21.     disable the speakerphone. If the speakerphone is enabled the user
  22.     can select the speaker volume. The microphone sensitivity cannot 
  23.     be adjusted.
  24.  
  25. *************************************************************************************************/
  26.  
  27. /******************************************** HEADERS *******************************************/
  28.  
  29. #include "TextUtils.h"
  30.  
  31. #include "TestModule.h"
  32.  
  33. /****************************************** DEFINITIONS *****************************************/
  34.  
  35. #define    rGetThreeNumbersDLOG    10000
  36. #define    kNumber1                3
  37. #define    kNumber2                5
  38. #define    kNumber3                7
  39.  
  40. /****************************************** PROTOTYPES ******************************************/
  41.  
  42. short    GetThreeNumbers (short * , short *, short *);
  43. void     DoTest (CHRSPtr paramPtr);
  44.  
  45. /************************************************************************************************/
  46. /************************************************************************************************/
  47.  
  48.  
  49. pascal short TestModule (CHRSPtr paramPtr)
  50. {
  51.     short    returnValue = noErr;
  52.     
  53.     if (paramPtr->version <= kTestModuleVersion) {
  54.         
  55.         DoTest (paramPtr);
  56.         
  57.     }
  58.     else
  59.         returnValue = kWrongVersion;
  60.         
  61.     return (returnValue);
  62. }
  63.  
  64.  
  65. short    GetThreeNumbers (short * number1, short * number2, short * number3)
  66. {
  67.     short        itemKind;
  68.     Handle        itemHand;
  69.     Rect        itemRect;
  70.     short        itemHit;
  71.     DialogPtr    theDialog;
  72.     Str255        itemStr;
  73.     long        tlong;
  74.     
  75.     if ((theDialog = GetNewDialog (rGetThreeNumbersDLOG, nil, (WindowPtr)(-1L))) != nil) {
  76.         GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  77.         SelIText (theDialog, kNumber1, 0, 32767);
  78.         
  79.         ShowWindow (theDialog);
  80.         
  81.         ModalDialog (nil, &itemHit);
  82.         
  83.         if (itemHit == ok) {
  84.             GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  85.             GetIText (itemHand, itemStr);
  86.             StringToNum (itemStr, &tlong);
  87.             *number1 = tlong;
  88.  
  89.             GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
  90.             GetIText (itemHand, itemStr);
  91.             StringToNum (itemStr, &tlong);
  92.             *number2 = tlong;
  93.  
  94.             GetDItem (theDialog, kNumber3, &itemKind, &itemHand, &itemRect);
  95.             GetIText (itemHand, itemStr);
  96.             StringToNum (itemStr, &tlong);
  97.             *number3 = tlong;
  98.         }
  99.         
  100.         DisposeDialog (theDialog);
  101.     }
  102.     else
  103.         itemHit = -1;
  104.     
  105.     return (itemHit);
  106. }
  107.  
  108.  
  109. void DoTest (CHRSPtr paramPtr)
  110. {
  111.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  112.     short        itemHit;
  113.     OSErr        errCode;
  114.     short        v1, v2, v3;
  115.     
  116.     if ((itemHit = GetThreeNumbers (&v1, &v2, &v3)) == ok) {
  117.         if (v1 == 0) {
  118.             Print (paramPtr, "SpeakerPhone off");
  119.             v3 = 0;
  120.             if ((errCode = TELSetVolume (termHand, telBuiltinSPVol, &v3, 1)) != noErr)
  121.                 Print (paramPtr, "### TELSetVolume failed : %d", errCode);
  122.             if ((errCode = TELSetVolume (termHand, telBuiltinSPMicVol, &v3, 1)) != noErr)
  123.                 Print (paramPtr, "### TELSetVolume failed : %d", errCode);
  124.         }
  125.         else {
  126.             Print (paramPtr, "SpeakerPhone on");
  127.             if ((errCode = TELSetVolume (termHand, telBuiltinSPVol, &v2, 2)) != noErr)
  128.                 Print (paramPtr, "### TELSetVolume failed : %d", errCode);
  129.             if ((errCode = TELSetVolume (termHand, telBuiltinSPMicVol, &v3, 2)) != noErr)
  130.                 Print (paramPtr, "### TELSetVolume failed : %d", errCode);
  131.         }
  132.     }
  133.     else
  134.         if (itemHit == -1)
  135.             Print (paramPtr, "### Unable to get a DLOG resource");
  136. }
  137.  
  138.  
  139.